/*********************************************************
          File Name:11.7.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sun 20 Sep 2015 07:47:23 PM CST
**********************************************************/

#include <iostream>
#include <vector>
#include <map>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::vector;

auto store(void) -> std::map<string, vector<string>>
{
        std::map<string, vector<string>> family;
        string last_name, child_name;

        cout << std::unitbuf;
        cout << "Enter Last Name(C-D) to exit: ";

        while(cin >> last_name)
        {
                cout << "Enter child name: ";
                while(cin >> child_name)
                {
                        family[last_name].push_back(child_name);
                        cout << "Enter child name: ";
                }
                cin.clear();
                cout << "\nEnter Last Name: ";
        }

        return family;
}

int main()
{
        auto family = store();

        cout << endl;

        for(const auto &x: family)
        {
                cout << "Last Name:--> " << x.first << endl;
                for(auto it = x.second.begin(); it != x.second.end(); ++it)
                {
                        cout << "Child Name:--> " << *it << endl;
                }
        }

        return 0;
}
